// main_view.dart
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../discover/pages/stock_list_view.dart';
import '../../position/pages/position_page.dart';
import '../../condition/pages/buy_conditions_view.dart';
import '../../settings/pages/settings_view.dart';
import '../controllers/main_view_controller.dart';


class MainView extends GetView<MainViewController> {
  const MainView({super.key});

  @override
  Widget build(BuildContext context) {
    final List<Widget> pages = [
      PositionPage(),
      StockListView(),
      BuyConditionsView(),
      SettingsView()
    ];

    return Scaffold(
      body: Obx(() => pages[controller.currentIndex.value]),
      bottomNavigationBar: Obx(() {
        return BottomNavigationBar(
          fixedColor: Colors.red,
          type: BottomNavigationBarType.fixed,
          currentIndex: controller.currentIndex.value,
          onTap: controller.bottomNavigationBarTap,
          items: [
            BottomNavigationBarItem(icon: Icon(Icons.launch), label: "持仓"),
            BottomNavigationBarItem(
                icon: Icon(Icons.input_rounded), label: "发现"),
            BottomNavigationBarItem(icon: Icon(Icons.add_alarm), label: "条件"),
            BottomNavigationBarItem(icon: Icon(Icons.settings), label: "设置"),
          ],
        );
      }),
    );
  }
}